package com.utils;

import org.junit.Test;

import java.util.ArrayList;

public class ArrayToStr3 {

    @Test
    public void test() {
        ArrayList<Long> list = new ArrayList<>();
        String[] lStrArray = numStr.split("\n");
        for (String lStr : lStrArray) {
            list.add(Long.valueOf(lStr));
        }
//        list.sort(Long::compareTo);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); ++i) {
            sb.append(list.get(i)).append(",");
            if (i > 0 && i % 300 == 0) {
                sb.append("\n");
            }
        }
        System.out.println("数量共: " + list.size());
//        System.out.println(sb.subSequence(0, sb.length() - 1));
        System.out.println(sb);
    }

    String numStr = "23974921\n" +
            "23974922\n" +
            "23974924\n" +
            "23974926\n" +
            "23974930\n" +
            "23974939\n" +
            "23974942\n" +
            "23974947\n" +
            "23974950";
}
